<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class UserRecord extends MY_Controller {
	public function __construct(){
		parent::__construct();
		$this->isLogin();
		$this->isItAdministrator();//不是超级管理员
		$this->load->model('UserRecord_model');
	}
	public function userRecordList(){
		$where=array();
		if(isset($_POST['type'])){
			$where['type']=array('like',$_POST['type']);
		}
		$result=$this->UserRecord_model->pm_user_record_ajax_list($where);
		//获取管理员信息
		$userid_array=array();
		$userlistinfo=array();
		if(!empty($result['list'])){
			foreach($result['list'] as $k=>$v){
				$userid_array[]=$v['uid'];
			}
			if(!empty($userid_array)){
				$userlist=$this->UserRecord_model->pm_user_info($userid_array,'id,name');
				foreach ($userlist as $k => $v) {
					$userlistinfo[$v['id']]=$v['name'];
				}
			}
			foreach ($result['list'] as $k => $v) {
				$v['username']='';
				if(isset($userlistinfo[$v['uid']])){
					$v['username']=$userlistinfo[$v['uid']];
				}
				$result['list'][$k]=$v;
			}
		}

		$this->assign('list',$result['list']);
		$this->assign('pageshow',$result['pageshow']);
		if(isset($_POST['page'])){
			$html=$this->fetch('userrecord/list_ajax.html');
			$result['html']=$html;
			ajax_return(1,'success',$result);
		}
		$this->display('userrecord/list.html');
	}
}
?>
